]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/scroll-view: Expose adjustments as properties
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 15 Nov 2023 12:50:42 +0000 (13:50 +0100)
committerMarge Bot <marge-bot@gnome.org>
Sat, 18 Nov 2023 18:00:43 +0000 (18:00 +0000)
The adjustments are currently only accessible indirectly via
the scroll bars. It is a bit odd to expose internal children,
and as nearly all users only access them for the adjustments,
it makes sense to expose those instead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3020>

src/st/st-scroll-view.c
src/st/st-scroll-view.h

index 3313307deb32e624cc6812181f00eaa87588e663..b12c8fd1d05c522ccab5cf216332f739b1d508c8 100644 (file)
@@ -99,6 +99,8 @@ enum {
   PROP_CHILD,
   PROP_HSCROLL,
   PROP_VSCROLL,
+  PROP_HADJUSTMENT,
+  PROP_VADJUSTMENT,
   PROP_HSCROLLBAR_POLICY,
   PROP_VSCROLLBAR_POLICY,
   PROP_HSCROLLBAR_VISIBLE,
@@ -131,6 +133,12 @@ st_scroll_view_get_property (GObject    *object,
     case PROP_VSCROLL:
       g_value_set_object (value, priv->vscroll);
       break;
+    case PROP_HADJUSTMENT:
+      g_value_set_object (value, priv->hadjustment);
+      break;
+    case PROP_VADJUSTMENT:
+      g_value_set_object (value, priv->vadjustment);
+      break;
     case PROP_HSCROLLBAR_POLICY:
       g_value_set_enum (value, priv->hscrollbar_policy);
       break;
@@ -888,6 +896,30 @@ st_scroll_view_class_init (StScrollViewClass *klass)
                          ST_TYPE_SCROLL_BAR,
                          ST_PARAM_READABLE);
 
+  /**
+   * StScrollView:hadjustment:
+   *
+   * The horizontal #StAdjustment for the #StScrollView.
+   */
+  props[PROP_HADJUSTMENT] =
+    g_param_spec_object ("hadjustment",
+                         "StAdjustment",
+                         "Horizontal scroll adjustment",
+                         ST_TYPE_ADJUSTMENT,
+                         ST_PARAM_READABLE);
+
+  /**
+   * StScrollView:vadjustment:
+   *
+   * The vertical #StAdjustment for the #StScrollView.
+   */
+  props[PROP_VADJUSTMENT] =
+    g_param_spec_object ("vadjustment",
+                         "StAdjustment",
+                         "Vertical scroll adjustment",
+                         ST_TYPE_ADJUSTMENT,
+                         ST_PARAM_READABLE);
+
   /**
    * StScrollView:vscrollbar-policy:
    *
@@ -1169,6 +1201,46 @@ st_scroll_view_get_vscroll_bar (StScrollView *scroll)
   return priv->vscroll;
 }
 
+/**
+ * st_scroll_view_get_hadjustment:
+ * @scroll: a #StScrollView
+ *
+ * Gets the horizontal #StAdjustment of the #StScrollView.
+ *
+ * Returns: (transfer none): the horizontal adjustment
+ */
+StAdjustment *
+st_scroll_view_get_hadjustment (StScrollView *scroll)
+{
+  StScrollViewPrivate *priv;
+
+  g_return_val_if_fail (ST_IS_SCROLL_VIEW (scroll), NULL);
+
+  priv = st_scroll_view_get_instance_private (scroll);
+
+  return priv->hadjustment;
+}
+
+/**
+ * st_scroll_view_get_vadjustment:
+ * @scroll: a #StScrollView
+ *
+ * Gets the vertical #StAdjustment of the #StScrollView.
+ *
+ * Returns: (transfer none): the vertical adjustment
+ */
+StAdjustment *
+st_scroll_view_get_vadjustment (StScrollView *scroll)
+{
+  StScrollViewPrivate *priv;
+
+  g_return_val_if_fail (ST_IS_SCROLL_VIEW (scroll), NULL);
+
+  priv = st_scroll_view_get_instance_private (scroll);
+
+  return priv->vadjustment;
+}
+
 /**
  * st_scroll_view_get_column_size:
  * @scroll: a #StScrollView
index 4a59d28ea10e2485e6848c61b0aaf064b7325f27..9d300a402e0dc6a4d13083522ee7a342de35d286 100644 (file)
@@ -56,6 +56,9 @@ void          st_scroll_view_set_child           (StScrollView *scroll,
 ClutterActor *st_scroll_view_get_hscroll_bar     (StScrollView *scroll);
 ClutterActor *st_scroll_view_get_vscroll_bar     (StScrollView *scroll);
 
+StAdjustment *st_scroll_view_get_hadjustment     (StScrollView *scroll);
+StAdjustment *st_scroll_view_get_vadjustment     (StScrollView *scroll);
+
 gfloat        st_scroll_view_get_column_size     (StScrollView *scroll);
 void          st_scroll_view_set_column_size     (StScrollView *scroll,
                                                   gfloat        column_size);